<%@ page import="java.io.File" %>
<%@ page import="com.education.service.bean.ActivityBean" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Fan307
  Date: 2016/11/23
  Time: 15:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>verifyFiles.jsp</title>
</head>
<body>
<script type="text/javascript">
    function getSelectedFolder(){
        var selectedFolder = document.getElementById("selectFolder").value;
        //window.location.href = "/VerifyFilesServlet?SelectedFolder=" + selectedFolder;
        var folder1 = document.getElementById("infolder").value;
        var folder2 = folder1 + "upload\\" +selectedFolder;
//        alert(folder2);

        var catagory=document.getElementById("catagoryFolder").value;
        var school=document.getElementById("schoolFolder").value;
        var major=document.getElementById("majorFolder").value;
        var course=document.getElementById("courseFolder").value;
        var mergefolder= folder1 + "res\\" + catagory + "\\" + school + "\\" + major + "\\" +course;
//        alert(mergefolder);

        window.location.href = "${pageContext.request.contextPath}/MergeFolderServlet?SelectFolder=" + folder2 +"&MergeFolder=" + mergefolder;
    }

</script>
<h2>文件审核页面</h2>
显示需要审核的文件夹：<br>
<%
    String uploadParent = application.getRealPath("/");
//    System.out.println(uploadParent);
    System.out.println(uploadParent + "upload");
    String folder = uploadParent ;//+ "upload\\";
    File file = new File(uploadParent + "upload");
    File[] files = file.listFiles();
    for(File e : files)
    {
       out.print(e.getName());
        out.print("<br>");
    }
//    File file=new File("c:\\");
//    File[] files=file.listFiles();
//    for(File f :files)
//    {
//    out.println(f.getName());
//        out.println("<br>");
//    }
%>
<input id="infolder" type="text" value="<%=folder%>" style="display: none"/>
<br><hr>
选择需要移动的文件夹：<br>
<select id = "selectFolder" >
    <%
        for(File e1:files)
        {
    %>
    <option value="<%=e1.getName()%>"><%=e1.getName()%></option>
    <%
        }
    %>
</select><br>
<%--<input type="button" value="确定" onclick="getSelectedFolder()"/>--%>
选择最终移动到的分类：<br>
<div >
    <select id="catagoryFolder" name="catagoryName">
        <%
            List<ActivityBean> infoCatagortyBean = (List) request.getAttribute("infocatagorybean");
            if(infoCatagortyBean.size() == 0)
            {
                out.println("当前选项为空");
            }
            else {
                for(int i=0;i<infoCatagortyBean.size();i++)
                {
                    String catagoryValue = infoCatagortyBean.get(i).getValue();
                    String catagoryName = infoCatagortyBean.get(i).getName();
        %>
        <option value="<%=catagoryValue%>"><%=catagoryValue%></option>
        <%
                }
            }
        %>
    </select>

    <select id="schoolFolder" name="schoolName">
        <%
            List<ActivityBean> infoSchoolBean = (List) request.getAttribute("infoschoolbean");
            if(infoSchoolBean.size() == 0)
            {
                out.println("当前选项为空");
            }
            else {
                for(int i=0;i<infoSchoolBean.size();i++)
                {
                    String schoolValue = infoSchoolBean.get(i).getValue();
                    String schoolName = infoSchoolBean.get(i).getName();
        %>
        <option value="<%=schoolValue%>"><%=schoolValue%></option>
        <%
                }
            }
        %>
    </select>

    <select id="majorFolder" name="majorName">
        <%
            List<ActivityBean> infoMajorBean = (List) request.getAttribute("infomajorbean");
            if(infoMajorBean.size() == 0)
            {
                out.println("当前选项为空");
            }
            else {
                for(int i=0;i<infoMajorBean.size();i++)
                {
                    String majorValue = infoMajorBean.get(i).getValue();
                    String majorName = infoMajorBean.get(i).getName();
        %>
        <option value="<%=majorValue%>"><%=majorValue%></option>
        <%
                }
            }
        %>
    </select>

    <select id="courseFolder" name="courseName">
        <%
            List<ActivityBean> infoCourseBean = (List) request.getAttribute("infocoursebean");
            if(infoCourseBean.size() == 0)
            {
                out.println("当前选项为空");
            }
            else {
                for(int i=0;i<infoCourseBean.size();i++)
                {
                    String courseValue = infoCourseBean.get(i).getValue();
                    String courseName = infoCourseBean.get(i).getName();
        %>
        <option value="<%=courseValue%>"><%=courseValue%></option>
        <%
                }
            }
        %>
    </select>

    <%--<input type="button" value="确定" onclick="getSelectedValue()"/>--%>
</div>
<input type="button" value="确定" onclick="getSelectedFolder()"/>
</body>
</html>
